
use "../final_1.dta", clear

preserve			   

*Table 1 Panel A
local tablename "tab_1a"
local table=1
local col=1
estimates clear

foreach var of varlist temperature humid pm25_level pm10_level total_people week_of_year dow {
reg `var' warm team warm_team, cluster(date_room)
su `var' if warm == 0 & team == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team warm_team, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))	

*Table 1 Panel B
local tablename "tab_1b"
local table=1
local col=1
estimates clear

foreach var of varlist tempmax tempmin temp humidity precip {
reg `var' warm team warm_team, cluster(date_room)
su `var' if warm == 0 & team == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team warm_team, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))				   
			   
restore			   


*Table 2 Panel A
local tablename "tab_2a"
local table=1
local col=1
estimates clear

foreach var of varlist any_features total_features {
reg `var' warm team warm_team, cluster(date_room)
su `var' if warm == 0 & team == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team warm_team, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))	

			   
*Table 2 Panel B
local tablename "tab_2b"
local table=1
local col=1
estimates clear

foreach var of varlist total_characters chars_per_min time_in_room time_elapsed_minutes any_breaks {
reg `var' warm team warm_team, cluster(date_room)
su `var' if warm == 0 & team == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team warm_team, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))	
			   
			   


	   
*Table 3 Panel A			   
local tablename "tab_3a"
local table=1
local col=1
estimates clear

foreach var of varlist any_features total_features  {
reg `var' warm team_sex_mix warm_sex_mix , cluster(date_room)
su `var' if warm == 0 & team == 1 & team_sex_mix == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}



esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team_sex_mix warm_sex_mix team_exp_mix warm_exp_mix, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))

*Table 3 Panel B	
local tablename "tab_3b"
local table=1
local col=1
estimates clear

foreach var of varlist total_characters chars_per_min  time_in_room  time_elapsed_minutes any_breaks {
reg `var' warm team_sex_mix warm_sex_mix , cluster(date_room)
su `var' if warm == 0 & team == 1 & team_sex_mix == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}



esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team_sex_mix warm_sex_mix team_exp_mix warm_exp_mix, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))			   

			   
			   
*Table 4 Panel A				   
local tablename "tab_4a"
local table=1
local col=1
estimates clear


foreach var of varlist any_features total_features   {

reg `var' warm team_exp_mix warm_exp_mix , cluster(date_room)
su `var' if warm == 0 & team == 1 & team_exp_mix == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}


esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team_sex_mix warm_sex_mix team_exp_mix warm_exp_mix, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))		
			   

*Table 4 Panel B			   
local tablename "tab_4b"
local table=1
local col=1
estimates clear


foreach var of varlist total_characters chars_per_min  time_in_room  time_elapsed_minutes any_breaks   {

reg `var' warm team_exp_mix warm_exp_mix , cluster(date_room)
su `var' if warm == 0 & team == 1 & team_exp_mix == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}


esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team_sex_mix warm_sex_mix team_exp_mix warm_exp_mix, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))					   
			   

			   
*Table 5 Panel A			   
local tablename "tab_5a"
local table=1
local col=1
estimates clear

foreach var of varlist any_features total_features  {
reg `var' warm dissimilar_2 dissimilar_3  warm_dissimilar_2 warm_dissimilar_3, cluster(date_room)
su `var' if warm == 0 & team == 1 & dissimilar_1 == 1
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}


esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm dissimilar_2 dissimilar_3 warm_dissimilar_2 warm_dissimilar_3 ///
			   diss_2 diss_3 diss_4 warm_diss_2 warm_diss_3 warm_diss_4, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))				   

*Table 5 Panel B			   
local tablename "tab_5b"
local table=1
local col=1
estimates clear

foreach var of varlist total_characters chars_per_min  time_in_room  time_elapsed_minutes any_breaks {
reg `var' warm dissimilar_2 dissimilar_3  warm_dissimilar_2 warm_dissimilar_3, cluster(date_room)
su `var' if warm == 0 & team == 1 & dissimilar_1 == 1
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}


esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm dissimilar_2 dissimilar_3 warm_dissimilar_2 warm_dissimilar_3 ///
			   diss_2 diss_3 diss_4 warm_diss_2 warm_diss_3 warm_diss_4, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))
		   
*Figure A2 
hist total_features, frac
graph export  "$outfig/fig_a2.pdf", replace

			   
*Figure A3			   
label var diss "Team Composition"
hist diss, frac xlabel(0 "Dissimilar = 0" 1 "Dissimilar Semester" 2 "Dissimilar Gender" 3 "Dissimilar = 2", labsize(small) angle(30))
graph export  "$outfig/fig_a3.pdf", replace		


*Table A1			   
local tablename "tab_a1"
local table=1
local col=1
estimates clear

foreach var of varlist any_features atleast_2_features atleast_3_features atleast_4_features all_features total_features {
reg `var' warm team warm_team, cluster(date_room)
su `var' if warm == 0 & team == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm team warm_team, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))	


*Table A3
local tablename "tab_a3"
local table=1
local col=1
estimates clear

foreach var of varlist any_features total_features  {
reg `var' warm sex warm_sex if team == 0, cluster(date_room)
su `var' if warm == 0 & team == 0 & sex == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'
}
foreach var of varlist any_features total_features  {
reg `var' warm high_exp warm_high_exp if team == 0, cluster(date_room)
su `var' if warm == 0 & team == 0 & high_exp == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}

foreach var of varlist any_features total_features  {
reg `var' warm sex high_exp sex_high_exp warm_sex warm_high_exp warm_sex_high_exp if team == 0, cluster(date_room)
su `var' if warm == 0 & team == 0 & sex_high_exp == 0
estadd scalar ymean = r(mean)
estimates store cT`table'C`col++'

}


esttab cT`table'C* using "$outtab/`tablename'.tex", replace f ///
               label booktabs b(3) p(3) eqlabels(none) alignment(S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
               keep (warm sex high_exp sex_high_exp warm_sex warm_high_exp warm_sex_high_exp, relax) ///
			   star(* 0.10 ** 0.05 *** 0.01) ///
               cells("b(fmt(2)star)" "se(fmt(2)par)") ///
			   stats(ymean N r2, fmt(2 0 3) layout("\multicolumn{1}{c}{@}") ///
			   labels(`"Control Mean"' `"Observations"' `"\(R^{2}\)"'))			   